const pool = require('./db');

const queryCategoriesDB = () => {
    return new Promise((resolve, reject) => {
        pool.getConnection(function (err, connection) {
            if (err) throw err; // 错误
            connection.query('SELECT * FROM articlecate', function (error, results, fields) {
                // 首先释放资源
                connection.release();
                // 处理错误
                if (error) {
                    reject(error);
                } else {
                    resolve(results);
                }
            });
        })
    });
}

exports.queryCategoriesDB = queryCategoriesDB;